package cn.org.donald.handler;

import cn.org.donald.base.HttpResult;
import cn.org.donald.base.ServiceException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author : Donald
 * @since : 2021/3/17 13:31
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(ServiceException.class)
    public HttpResult serviceException(ServiceException e) {
        HttpResult result = new HttpResult();
        result.setCode(e.getCode());
        result.setInfo(e.getInfo());
        return result;
    }
}
